package com.example.demo.controlller;

import com.example.demo.pojo.PageBean;
import com.example.demo.pojo.Result;
import com.example.demo.pojo.ResultProject;
import com.example.demo.service.ResultProjectservice;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/ResultProject")
public class ResultProjectcontroller {
    @Autowired
    ResultProjectservice resultProjectservice;

    @RequestMapping("/queryName")
    @ResponseBody
    public Result queryName(String result){
        List<ResultProject> list=resultProjectservice.queryName(result);
        return Result.success(list);
    }

    @RequestMapping("/queryAll")
    @ResponseBody
    public Result queryAll(){
        List<ResultProject> list=resultProjectservice.queryAll();
        System.out.println(list);
        return Result.success(list);
    }

    @RequestMapping("/queryOnlyTwo")
    @ResponseBody
    public Result queryOnlyTwo(){
       List<String> s=resultProjectservice.queryOnlyTwo();
        return Result.success(s);
    }
    @RequestMapping("/queryResult")
    @ResponseBody
    public Result queryResult(String project){
        List<String> list=resultProjectservice.queryResult(project);
        return Result.success(list);
    }
    @RequestMapping("/queryOne")
    @ResponseBody
    public Result queryOne(String result){
        List<ResultProject> list=resultProjectservice.queryOne(result);
        return Result.success(list);
    }
   @RequestMapping("/add")
    @ResponseBody
    public Result insert(@RequestBody ResultProject resultProject){
        resultProjectservice.insert(resultProject);
        return  Result.success();
   }
   @RequestMapping("/delete")
    @ResponseBody
    public Result deleteById(Integer rpId){
        resultProjectservice.deleteById(rpId);
        return Result.success();
   }
   @RequestMapping("/update")
    @ResponseBody
    public  Result update(@RequestBody ResultProject resultProject){
        resultProjectservice.update(resultProject);
        return Result.success();
   }
   @GetMapping("/callQueryAll")
    @ResponseBody
    public  Result callQueryAll(){
       List<ResultProject> list=resultProjectservice.callQueryAll();
       return Result.success(list);

   }
    @RequestMapping("/page1")
    @ResponseBody
    public Result page(@RequestParam(defaultValue = "1")Integer page, @RequestParam(defaultValue = "10")Integer pageSize){
        PageBean pageBean=resultProjectservice.page(page,pageSize);
        return Result.success(pageBean);
    }
    @RequestMapping("/test")
    @ResponseBody
    public Result test(String [] selectedData){
        List<String> list = resultProjectservice.test(selectedData);
        for (String s : list) {
            System.out.println(s);
        }
        return Result.success(list);

    }

    @GetMapping("/projects")
    @ResponseBody
    public Result projects(){
        List<String> list = resultProjectservice.projects();
        for (String s : list) {
            System.out.println(s);
        }
        return Result.success(list);

    }
}
